package com.example.testapplication;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import android.widget.Toast;

import java.util.List;

/**
 * @author wwq on 2019/7/31  15:53.
 */
public class SearchHistoryAdapter extends BaseAdapter {
    private Context context;
    private List<SearchHistory> list;

    public SearchHistoryAdapter(Context context, List<SearchHistory> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return 0;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        final SearchHistory tv = (SearchHistory) getItem(position);
        ViewHolder viewHolder;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_search_history, null);
            viewHolder = new ViewHolder();
            viewHolder.tvFlowLayout = (TextView) convertView.findViewById(R.id.rcHistory);
            viewHolder.tvFlowLayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Toast.makeText(context,tv.getHistory()+"",Toast.LENGTH_SHORT).show();
                }
            });
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.tvFlowLayout.setText(tv.getHistory());

        return convertView;
    }

    class ViewHolder {
        TextView tvFlowLayout;

    }
}
